package Text_12;

import java.util.Random;

public class TextCode {

	public static void main(String[] args) {
		Random r = new Random();
		//定义一个数组
		int[] tempArry = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
		//遍历数组，用随机数与数组下标进行交换
		for (int i=0;i<tempArry.length;i++) {
			int index = r.nextInt(tempArry.length);
			int temp = tempArry[i];
			tempArry[i] = tempArry[index];
			tempArry[index] = temp;
		}
		//遍历数组
		for(int i=0;i<tempArry.length;i++) {
			System.out.print(tempArry[i]+" ");
		}
		System.out.println();
		int index = 0;
		int[][] data = new int[4][4];
		for(int i=0;i<data.length;i++) {
			for(int j=0;j<data.length;j++) {
				data[i][j] = tempArry[index];
				index++;
			}
		}
		for(int i=0;i<data.length;i++) {
			for(int j=0;j<data.length;j++) {
				System.out.print(data[i][j]+" ");
				
			}
			System.out.println();
		}

	}

}
